/**
 * @file lv_watch_obj.h
 *
 */
#ifndef LV_WATCH_OBJ_H
#define LV_WATCH_OBJ_H

#ifdef __cplusplus
extern "C" {
#endif

/*********************
 *      INCLUDES
 *********************/

#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lvgl.h"
#include "lv_watch_conf.h"
#else
#include "../../../lvgl/lvgl.h"
#include "../../../lv_watch_conf.h"
#endif

#if USE_LV_WATCH_OBJ != 0

/*********************
 *      DEFINES
 *********************/
#define LV_WATCH_OBJ_HIDE_TIME 50//300

/**********************
 *      TYPEDEFS
 **********************/
enum
{
    /*General animation mode*/
    LV_WATCH_ANIM_HOR_RIGHT_HIDE,
    LV_WATCH_ANIM_VER_UP_HIDE,
    LV_WATCH_LEFT_OR_RIGHT_SLIDE_CALLBACK, /*phone, left slide call back */
    LV_WATCH_ANIM_NO,
};
typedef uint8_t lv_watch_anim_mode_t;

typedef void (*lv_watch_obj_cb_t)(void *);

typedef struct {
    /*New data for this type */
    lv_obj_t * activity_obj;
    void * free_ptr;              /*Application specific pointer (set it freely)*/
    lv_point_t point_last;
    lv_point_t point_start;
    lv_point_t point_now;
    uint8_t hor_drag_start;
    uint8_t ver_drag_start;
    lv_watch_anim_mode_t anim_mode;
    uint16_t anim_time;
    uint8_t slide_enable :1;
    uint8_t draging :1;
    uint8_t drag_hor :1;
    uint8_t element_click_en :1;
    uint8_t is_drag_right :1;
    uint8_t is_drag_up :1;
    lv_watch_obj_cb_t slide_left_pressing_cb;
    lv_watch_obj_cb_t slide_right_pressing_cb;
    lv_watch_obj_cb_t slide_left_press_lost_cb;
    lv_watch_obj_cb_t slide_right_press_lost_cb;
    lv_watch_obj_cb_t slide_up_pressing_cb;
    lv_watch_obj_cb_t slide_down_pressing_cb;
    lv_watch_obj_cb_t slide_up_press_lost_cb;
    lv_watch_obj_cb_t slide_down_press_lost_cb;
} lv_watch_obj_ext_t;

enum
{
    SLIDE_LEFT_PRESSING_CB,
    SLIDE_LEFT_PRESS_LOST_CB,
    SLIDE_RIGHT_PRESSING_CB,
    SLIDE_RIGHT_PRESS_LOST_CB,
    SLIDE_UP_PRESSING_CB,
    SLIDE_UP_PRESS_LOST_CB,
    SLIDE_DOWN_PRESSING_CB,
    SLIDE_DOWN_PRESS_LOST_CB,
};
typedef uint8_t lv_watch_anim_cb_type_t;


typedef struct
{
    uint8_t sliding_up_en :1;
    uint8_t sliding_down_en :1;
    uint8_t sliding_left_en :1;
    uint8_t sliding_right_en :1;
} lv_watch_obj_element_free_ptr_client_t;

/**********************
 * GLOBAL PROTOTYPES
 **********************/

lv_obj_t * lv_watch_obj_create(lv_obj_t * activity_obj);
void lv_watch_obj_set_free_ptr(lv_obj_t * obj, void * free_p);
void * lv_watch_obj_get_free_ptr(const lv_obj_t * obj);
lv_res_t lv_watch_obj_set_anim_mode(lv_obj_t * obj, lv_watch_anim_mode_t anim_mode);
lv_res_t lv_watch_obj_set_slide_enable(lv_obj_t * obj, bool slide_enable);
void lv_watch_obj_add_element(lv_obj_t * element);
void lv_watch_obj_cleanup(lv_obj_t * element);
void lv_watch_obj_set_anim_cb(lv_obj_t * obj, lv_watch_anim_cb_type_t cb_type, void (*cb)(lv_obj_t *));
lv_res_t lv_watch_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
void lv_watch_obj_reset_anim_cb(lv_obj_t * obj);
void lv_watch_obj_set_left_slide_cb(lv_obj_t * obj, void (*cb)(lv_obj_t *));
void lv_watch_obj_set_right_slide_cb(lv_obj_t * obj, void (*cb)(lv_obj_t *));
void lv_watch_obj_set_up_slide_cb(lv_obj_t * obj, void (*cb)(lv_obj_t *));
void lv_watch_obj_set_down_slide_cb(lv_obj_t * obj, void (*cb)(lv_obj_t *));
lv_obj_t * lv_watch_obj_get_obj_from_activity_obj(lv_obj_t * activity_obj);
void lv_watch_obj_recover_element_clicked_en(lv_obj_t * obj);
void lv_watch_obj_recover_element_clicked_en_by_activity(lv_anim_t * a);
lv_obj_t * lv_watch_obj_get_activity(lv_obj_t * obj);
lv_res_t lv_watch_obj_hor_hide_action(lv_obj_t * obj, lv_coord_t new_x);
lv_res_t lv_watch_obj_ver_hide_action(lv_obj_t * activity_obj, lv_coord_t new_y);

/**********************
 *      MACROS
 **********************/

#endif /*USE_LV_WATCH_OBJ*/

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*LV_WATCH_OBJ_H*/
